import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
const state = {
    username: localStorage.getItem('username') || '',
    tradeTypeVal:'',
    tradeWayVal:'',
    page:''
}
const mutations = {
  setUsername: (state, username) => {
      state.username = username
      localStorage.setItem('username', username)
  },
  loginOut:state => {
     state.username = ''
  },
  setTradeTypeVal:(state,data) => {
    state.tradeTypeVal = data;
},
setTradeWayVal:(state,data) => {
    state.tradeWayVal = data; 
},
setPage:(state,e)  => {
    state.page = e;
    console.log(state.page);
}
}
const actions = {}
const getters = {
  username: (state) => localStorage.getItem('username')
}
export default new Vuex.Store({
    state,
    getters,
    actions,
    mutations
})